import { Schema, model } from 'mongoose';

export interface IRepoPages {
  _id?: Schema.Types.ObjectId;
  createdAt?: Date;
  name: string;
  remark?: string;
  updatedAt?: Date;
}

export const RepoPagesModel = model<IRepoPages>(
  'RepoPagesModel',
  new Schema<IRepoPages>(
    {
      name: { required: true, type: String },
      remark: { type: String },
    },
    {
      // 自动添加createdAt和updatedAt时间戳
      timestamps: true,
      toObject: {
        getters: true, // 包含虚拟字段
        minimize: false, // 包含空对象
        versionKey: false, // 不包含 __v 版本键
        virtuals: true, // 包含虚拟属性
      },
    },
  ),
);
